<template>
	<view class="content">

		<!-- 顶部搜索 -->
		<!-- <view class="title-box">
			<view class="input-box" @click="openSearch">
				<view style="float: left;"><uni-icon type="search" size="28" class="search" color="#8e8e8e" style="margin-top: -10upx;"></uni-icon></view>
				<view style=" float: left; height:100%;"><input type="text" value="" placeholder="输入关键字搜索" class="input"  @confirm="Gosearch" v-model="searchName"/></view>
			</view>
			
		</view> -->
		<!-- 头部 -->
		<view class="title-box">
			<view @click="scanCode()" class="scan">
				<image
					src="http://rs.eonfox.cc/clzy/static/scan-ico.png"
					mode=""
					style="width:40upx; height:40upx;  "
				></image>
			</view>
			<view class="input-box" @click="openSearch">
				<view style="float: left;">
					<image src="../../static/search.png" mode=""
					style="width:40upx; height:40upx; margin-left: 10upx; margin-right: 10upx; margin-top: 10upx; "
					></image>
				</view>
				<view style=" float:left; height:100%;"><input type="text"  @confirm="Gosearch" v-model="searchName" placeholder="输入关键字搜索" class="input" /></view>
			</view>
		</view>
		<view class="newsContent" v-for="(item,index) in newslist" :key="index" :data-Businessid="item.type_id" @click="goDetails">
			<view class="newsContentList">
				<view class="newsContentBox" style="margin-right:10px">
					<image :src="address+item.image_id+'?imageView2/1/w/60/h/60'" ></image>
				</view>
				<view class="newsContentText">
					<view class="newsContentTextTitle">
						<text>{{item.name}}</text>
						<!-- <text class="newsData">{{item.time}}</text> -->
					</view>
					<!-- <text>{{item.info}}</text> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uniIcon from "@/components/uni-icon/uni-icon.vue"
	import eonfox from "@/components/eonfox/eonfox.js"
	import fns from '@/components/eonfox/fns.js';
	var ef = new eonfox();
	export default {
		name:"news",
		data() {
			return {
				newslist:[],
				newsId:'',
				address:'',
				searchName:''
			};
		},
		onLoad(){
			this.load();
		},
		components:{
			uniIcon
		},
		methods:{
			Gosearch(){
				uni.navigateTo({
					url:'../../pagesB/newList/newList?searchName='+this.searchName
				})
			},
			scanCode(){
				var _this=this
				var _this=this
				uni.showToast({
					// #ifdef H5
					title:'请使用微信小程序或APP',
					icon:'none',
					// #endif
					
					success(){
						setTimeout(function(){
							
						},1500)
					}
				})
				uni.scanCode({
					onlyFromCamera: true,
					success: function (res) {
						if(res.result){
							var data=JSON.parse(res.result);
							console.log('res:',data);
							if(!data.errno){
								if(data.type!='merchant_money_plus'){
									uni.showToast({
										title:'该二维码非收款二维码'
									})
								}else if(data.data.merchant_id){
									_this.merchant_id=data.data.merchant_id
									uni.navigateTo({
										url:'../../pagesB/payUser/payUser?mch_id='+data.data.merchant_id
									})
								}else{
									uni.showToast({
										title:'扫码失败',
										icon:'none'
									})
								}
							}else{
								uni.showToast({
									title:data.error,
									icon:'none'
								})
							}
						}
					}
				});
			},
			load(){
					var that=this;
					ef.submit({
					request:{
					s: ['APPLICATIONTYPEOPTION',[{module:"cms_article_type","parent_id":""}]],
					config: ['APPLICATIONCONFIG'],
					},
					callback: function(data) {
						console.log('列表', data);
						var dataList = fns.checkError(data,["s",'config'], function(erron, error) {
							uni.showToast({
								title: error,
								icon: 'none'
							})
						});
						
						if( !dataList ){
							return false;
						}
						if( dataList.config && dataList.config.qiniu_domain ){
							that.address = dataList.config.qiniu_domain;//获取七牛的域名
						}				
						console.log('address',that.address);
						that.newslist = dataList.s;
						console.log('输出',that.newslist)
					},				
                	error: function(err) {
									uni.showToast({
									title:'出错啦',
									icon:'none'
										})
										}
										
									});
			},
			goDetails:function(e){
				var newsId=e.currentTarget.dataset.businessid;
				console.log("目标",newsId);
				uni.navigateTo({
					url:'../../pagesB/newList/newList?newsId='+newsId  
					// 参数的传递 newsid 
				});
			}
			
		}
	}
</script>

<style>
	.status-contents{
		height: var(--status-bar-height);
	}
	.top-view{
		width: 100%;
		position: fixed;
		top: 0;
	}
	.status{
		height:var(--status-bar-height);
	}
</style>

<style scoped lang="stylus" ref="stylesheet/stylus">
	.content
		.title-box
			display flex
			justify-content center // 水平居中
			align-items center // 垂直居中
			flex-direction row//左到右
			width 710upx
			padding 0 20upx
			height 100upx
			.scan
				width 40upx
				height 40upx
			.input-box
				margin-left 20upx
				width 650upx
				height 58upx
				border 1upx solid #d3d3d3
				.search
					display inline-block
					position absolute
					top 0
					left 0
				.input
					width 80%
					display inline-block
					font-size 28upx
					text-align left
					line-height 100%
					height 100%
			.chat
				flex 1
		.tabBar
			border-bottom 1px solid #d3d3d3
			height 100upx
			text-align center
			line-height 100upx
			position relative
			.arrowleft
				float left
				width 50upx
				height 50upx
				position absolute
				left 10upx
				top 20upx
		.newsContent
			padding 0 40upx
			.newsContentList
				height 150upx
				border-bottom 1px solid #d3d3d3
				display flex
				// justify-content center   
				align-items center     
				flex-direction row
				.red
					background #E8315D
				.blue
					background #8DBAE6
				.purple
					background #7994E7
				.newsContentBox
					display inline-block
					width 60upx
					height 60upx
					border-radius 50%
					display flex
					justify-content center  
					align-items center   
					.allIocn
						width 50upx
						height 50upx
				.newsContentText
					width calc(100% - 60upx)
					display inline-block
					font-size 28upx
					.newsContentTextTitle
						font-size 30upx
						font-weight 600
						margin-bottom: 10upx
						.newsData
							float right
							color #BEC2C9
					
</style>

<style>
	
	image{
		width: 60upx;
		height: 60upx;
	}
	
</style>